grammar statesFile;

options 
{
	language = C;
}

@parser::includes
{
	#include "statesFileParser.h"
	#include "newGraph.h"
	#include "check.h"
	
	inline int getInt( ANTLR3_COMMON_TOKEN_struct* a //!<Antlr token struct
	) {return atoi((char*)a->getText(a)->chars);}
}


TYPE	: 'int' | 'bool';

ID  :	('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
    ;

INT :	'0'..'9'+
    ;

COMMENT
    :   '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
    |   '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
    ;

WS  :   ( ' '
        | '\t'
        | '\r'
        | '\n'
        ) {$channel=HIDDEN;}
    ;

getInitialState[VariablesMap & map]	:
	'initial'
	getState[map]
	;
	
getFinalState[VariablesMap & map]	:
	'final'
	getState[map]
	;

getState[VariablesMap & map] 	
	:	
	'{'
	(variable[map] )*
	 '}' 
	;

variable[VariablesMap & map]
	: TYPE ID '=' INT ';'
	{
		string t=(string)((char*)$TYPE.text->chars);
		NodeTypeInterface * decorator= new SimpleNodeType((t=="int"?INT_TYPE:BOOL_TYPE));
		map.insert(VariablesPair((string)((char*)$ID.text->chars),VariableInfo(decorator,getInt($INT))));
	}
	;
